package com.example.controller;

import com.example.common.result.Result;
import com.example.entity.mes.Unit;
import com.example.service.UnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin // 跨域
@RestController
@RequestMapping("/api/Unit")
@Api(tags = "设备管理控制接口")
public class UnitController {

    @Resource
    private UnitService unitService;

    @ApiOperation("根据登录人的id查询设备")
    @PostMapping("/queryUnit")
    @ResponseBody
    public Result queryUnit(Long id, String name, String status){
        return this.unitService.queryUnit(id,name,status);
    }

    @ApiOperation("根据设备id进行详细查询")
    @GetMapping("/queryUnitById")
    @ResponseBody
    public Result queryUnitById(Long id){
        return this.unitService.queryUnitById(id);
    }

    @ApiOperation("根据设备id进行物理删除")
    @DeleteMapping("/deleteUnit")
    public Result deleteUnit(Long id){
        return this.unitService.deleteUnit(id);
    }

    @ApiOperation("根据设备id查询的数据进行修改")
    @PutMapping("/updateUnit")
    public Result updateUnit(@RequestBody Unit unit){
        return this.unitService.updateUnit(unit);
    }

    @ApiOperation("新增设备,编码后端自动生成")
    @PostMapping("/insertUnit")
    public Result insertUnit(@RequestBody Unit unit){
        return this.unitService.insertUnit(unit);
    }

}
